#ifndef INVENTORY_H
#define INVENTORY_H

#include <map>
#include <string>


#include "ItemStack.h"
#include "AnimatedSprite.h"

class Item;

// Based off http://www.gamedev.net/reference/articles/article2163.asp.
class Inventory
{
public:
    Inventory(int inventoryBgId);
    void cleanUp();

    void render(sf::RenderWindow& window);
    void update(sf::RenderWindow& window);
    void move(sf::Vector2i move);

    void setShow(bool show);
    bool getShow();
    void swapShow(); //swaps from true to false / false to true

    const ItemStack& getStack(int item_id);
    const ItemStack& getStack(const Item& item);

    void addItem(const ItemPtr& item, size_t numberToAdd);

    AnimatedSprite getBgSprite() const;
private:

    //virtual void readFile(fileName);
    //virtual void writeFile(fileName) const;

    int rows; // size of inventory
    int columns; // size of inventory

	bool initialised;
    bool show;

    //Drag'n'drop
    bool wasLeftDown;
    bool isDragged;
    bool wasDragged;
    sf::Vector2i lastMousePosition;

    AnimatedSprite invBg;

    sf::Font invFont;
    sf::Text itemsInStack;

    typedef std::map<int, ItemStack> items_map;
    typedef items_map::iterator entry_it;
    items_map items;
};

typedef boost::shared_ptr<Inventory> InventoryPtr;

#endif